const readline = require("readline")
const r1 = readline.createInterface
({
    input:process.stdin,
    output:process.stdout,
})

let input_arr = []
r1.on('line',function(line)
{
    input_arr.push(line)
})

r1.on('close',function()
{
//     let input = `4
// 320124198808240056
// 12010X198901011234
// 110108196711301866
// 37070419881216001X`
// let input_arr = input.split('\n')
// console.log(input_arr)

let count = parseInt(input_arr[0])//看有多少个身份证，把4单拎出来
let quanzhong_arr = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
let is_all_passed = true
for(let i = 0;i < count;i++)
    {
        let id_no = input_arr[i+1]//跳过4，从第一个身份证号开始
        let result = 0
        for(let j = 0;j < 17;j++)
            {
                result += id_no[j]*quanzhong_arr[j]//每一个身份证都是一个数组
            }
        result = result % 11
        let check_arr = ['1','0','X','9','8','7','6','5','4','3','2']
        if(id_no[17] !== check_arr[result])
            {
                is_all_passed = false
                console.log(id_no)
            }
    }
    if(is_all_passed === true)
        {
            console.log('All passed')
        }
})
